home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / VMSBUILD.COM < prev    next >
Text File  |  1993-03-16  |  8KB  |  196 lines

  1. $ ! vms/vmsbuild.com -- compile and link NetHack 3.0 patchlevel 9    [pr]
  2. $ !
  3. $ ! usage:
  4. $ !   $ set default [.src]    !or [-.src] if starting from [.vms]
  5. $ !   $ @[-.vms]vmsbuild  [compiler-option]  [link-option]  [cc-switches]
  6. $ ! options:
  7. $ !    compiler-option :  either "VAXC" or "GNUC" or ""    !default VAXC
  8. $ !    link-option    :  either "SHARE[able]" or "LIB[rary]"    !default SHARE
  9. $ !    cc-switches    :  optional qualifiers for CC (such as "/noOpt/Debug")
  10. $ ! notes:
  11. $ !    If the symbol "CC" is defined, compiler-option is not used.
  12. $ !    The link-option refers to VAXCRTL (C Run-Time Library) handling;
  13. $ !      to specify it while letting compiler-option default, use "" as
  14. $ !      the compiler-option.
  15. $ !    To re-link without compiling, use "LINK" as special 'compiler-option';
  16. $ !      to re-link with GNUC library, 'CC' must begin with "G" (or "g").
  17. $ !    Default wizard definition moved to include/vmsconf.h.
  18. $
  19. $    vaxc_ = "CC/NOLIST/OPTIMIZE=NOINLINE"        !vaxc v3.x (2.x fixed below)
  20. $    gnuc_ = "GCC/CC1=""-fwritable-strings"""
  21. $    gnulib = "gnu_cc:[000000]gcclib/Library"    !(not used w/ vaxc)
  22. $ ! common CC options (/obj=file doesn't work for GCC 1.36, use rename instead)
  23. $    c_c_  = "/INCLUDE=[-.INCLUDE]"    !/DEFINE=(""WIZARD=""""GENTZEL"""""")
  24. $    if f$extract(1,3,f$getsyi("VERSION")).lts."4.6" then -
  25. $        c_c_ = c_c_ + "/DEFINE=(""VERYOLD_VMS"")"
  26. $ ! miscellaneous setup
  27. $    ivqual = %x00038240    !DCL-W-IVQUAL (used to check for ancient vaxc)
  28. $    abort := exit %x1000002A
  29. $ ! validate first parameter
  30. $    p1 := 'p1'
  31. $    c_opt = f$locate("|"+p1, "|VAXC|GNUC|LINK|SPECIAL|") !5
  32. $     if (c_opt/5)*5 .eq. c_opt then  goto p1_ok
  33. $    copy sys$input: sys$error:    !p1 usage
  34. %first arg is compiler option; it must be one of
  35.        "VAXC" -- use VAX C to compile everything
  36.    or  "GNUC" -- use GNU C to compile everything
  37.    or  "LINK" -- skip compilation, just relink nethack.exe
  38.    or  "SPEC[IAL]" -- just compile and link lev_comp.exe
  39.    or    ""   -- default operation (VAXC unless 'CC' is defined)
  40.  
  41. Note: if a DCL symbol for CC is defined, "VAXC" and "GNUC" are no-ops.
  42.       If the symbol value begins with "G" (or "g"), then the GNU C
  43.       library will be included in all link operations.  Do not rebuild
  44.       lev_comp with "SPECIAL" unless you have a CC symbol setup with
  45.       the proper options.
  46. $    abort
  47. $p1_ok:
  48. $ ! validate second parameter
  49. $    p2 := 'p2'
  50. $    l_opt = f$locate("|"+p2, "|SHAREABLE|LIBRARY__|") !10
  51. $     if (l_opt/10)*10 .eq. l_opt then    goto p2_ok
  52. $    copy sys$input: sys$error:    !p2 usage
  53. %second arg is VAXCRTL handling; it must be one of
  54.        "SHAREABLE" -- link with SYS$SHARE:VAXCRTL.EXE/SHAREABLE
  55.    or   "LIBRARY"  -- link with SYS$LIBRARY:VAXCRTL.OLB/LIBRARY
  56.    or      ""      -- default operation (use shareable image)
  57.  
  58. Note: for MicroVMS 4.x, "SHAREABLE" (which is the default) is required.
  59. $    abort
  60. $p2_ok:
  61. $ ! compiler setup; if a symbol for "CC" is already defined it will be used
  62. $     if f$type(cc).eqs."STRING" then  goto got_cc
  63. $    cc = vaxc_            !assume "VAXC" requested or defaulted
  64. $    if c_opt.eq.5 then  cc = gnuc_    !explicitly invoked w/ "GNUC" option
  65. $    if c_opt.ne.0 then  goto got_cc !"GNUC" or "LINK", skip compiler check
  66. $    ! we want to prevent function inlining with vaxc v3.x (/opt=noinline)
  67. $    !   but we can't use noInline with v2.x, so need to determine version
  68. $      set noOn
  69. $      msgenv = f$environment("MESSAGE")
  70. $      set message/noFacil/noSever/noIdent/noText
  71. $      cc/noObject _NLA0:/Include=[]     !strip 'noinline' if error
  72. $      sts = $status
  73. $    if sts then  goto reset_msg    !3.0 or later will check out OK
  74. $    ! must be dealing with vaxc 2.x; ancient version (2.2 or earlier)
  75. $    !   can't handle /include='dir', needs c$include instead
  76. $      cc = cc - "=NOINLINE" - ",NOINLINE" - "NOINLINE,"
  77. $      if sts.ne.IVQUAL then  goto reset_msg
  78. $        define/noLog c$include [-.INCLUDE]
  79. $        c_c_ = "/DEFINE=(""ANCIENT_VAXC"")"
  80. $        if f$extract(1,3,f$getsyi("VERSION")).lts."4.6" then -
  81. $        c_c_ = c_c_ - ")" + ",""VERYOLD_VMS"")"
  82. $reset_msg:
  83. $      set message 'msgenv'
  84. $      set On
  85. $got_cc:
  86. $    cc = cc + c_c_            !append common qualifiers
  87. $    if p3.nes."" then  cc = cc + p3 !append optional user preferences
  88. $    g := 'f$extract(0,1,cc)'
  89. $    if g.nes."G" then  gnulib = ""
  90. $    if g.eqs."G" then  gnulib = "," + gnulib
  91. $ ! linker setup; if a symbol for "LINK" is defined, we'll use it
  92. $    if f$type(link).nes."STRING" then  link = "LINK/NOMAP"
  93. $    if p4.nes."" then  link = link + p4 !append optional user preferences
  94. $    vaxcrtl = "sys$library:vaxcrtl.olb/Library"    !object library
  95. $     if l_opt.ne.0 then  goto vaxcrtl_ok
  96. $    vaxcrtl = "sys$disk:[]vaxcrtl.opt/Options"    !shareable image
  97. $     if f$search("vaxcrtl.opt").nes."" then  goto vaxcrtl_ok !assume its right
  98. $    create sys$disk:[]vaxcrtl.opt
  99. sys$share:vaxcrtl/Shareable
  100. sys$library:vaxcrtl/Library    !/Include=C$$TRANSLATE    !for link() substitute
  101. $vaxcrtl_ok:
  102. $ ! final setup
  103. $    nethacklib = "nethack.olb"
  104. $    milestone = "write sys$output f$fao("" !5%T "",0),"
  105. $     if c_opt.eq.10 then  goto link    !"LINK" requested, skip compilation
  106. $    rename     := rename/New_Vers
  107. $    touch     := set file/Truncate
  108. $    makedefs := $sys$disk:[]makedefs
  109. $    show symbol cc
  110. $!
  111. $!  compile and link makedefs, then nethack, finally lev_comp.
  112. $!
  113. $ milestone "<compiling...>"
  114. $ cc [-.vms]vmsmisc    !try simplest one first
  115. $ cc alloc.c
  116. $ if f$search("monst.c").eqs."" then  copy/Concat monst.c1+.c2 *.c
  117. $ cc monst.c
  118. $ milestone " (monst)"
  119. $ cc objects.c
  120. $     if c_opt.eq.15 then  goto special !"SPECIAL" requested, skip main build
  121. $ cc makedefs.c
  122. $ link makedefs.obj,monst.obj,objects.obj,vmsmisc.obj,-
  123.     'vaxcrtl''gnulib',sys$input:/Opt
  124. identification="makedefs 3.0.9"
  125. $ milestone "makedefs"
  126. $! create some build-time files
  127. $ makedefs -p    !pm.h
  128. $ makedefs -o    !onames.h
  129. $ makedefs -t    !trap.h
  130. $ makedefs -v    !date.h
  131. $! create new object library
  132. $ libr/Obj 'nethacklib'/Create=(Block=2000,Hist=2) vmsmisc.obj,alloc.obj/Insert
  133. $ if f$search(f$parse(".olb;-2",nethacklib)).nes."" then -
  134. $    purge/Keep=2 'nethacklib'
  135. $! compile most of the source files:
  136. $ c1 = "decl,version,[-.vms]vmsmain,[-.vms]vmsunix,[-.vms]vmstty," -
  137.       + "[-.others]random,[-.vms]vmstparam"
  138. $ c2 = "allmain,apply,artifact,attrib,bones,cmd,dbridge,demon,do,do_name," -
  139.       + "do_wear,dog,dogmove,dokick,dothrow,eat,end,engrave,exper,extralev"
  140. $ c3 = "fountain,getline,hack,invent,lock,mail,makemon,mcastu,mhitm,mhitu," -
  141.       + "mklev,mkmaze,mkobj,mkroom,mon,mondata,monmove,mthrowu,music,o_init"
  142. $ c4 = "objnam,options,pager,pickup,polyself,potion,pray,pri,priest,prisym," -
  143.       + "read,restore,rip,rnd,rumors,save,search,shk,shknam,sit,sounds,sp_lev"
  144. $ c5 = "spell,steal,termcap,timeout,topl,topten,track,trap,u_init,uhitm," -
  145.       + "vault,weapon,were,wield,wizard,worm,worn,write,zap"
  146. $! process all 5 lists of files
  147. $   i = 1
  148. $list_loop:
  149. $     list = c'i'    !get next list
  150. $     j = 0
  151. $file_loop:
  152. $    file = f$element(j,",",list)    !get next file
  153. $    if file.eqs."" .or. file.eqs."," then  goto list_done
  154. $    cc 'file'.c
  155. $    if f$extract(0,1,file).eqs."[" then -
  156. $        file = f$edit(f$parse(file,,,"NAME"),"LOWERCASE")
  157. $    libr/Obj 'nethacklib' 'file'.obj/Insert
  158. $    delete 'file'.obj;*
  159. $    milestone " (",file,")"
  160. $    j = j + 1
  161. $     goto file_loop
  162. $list_done:
  163. $     i = i + 1
  164. $   if i.le.5 then  goto list_loop
  165. $! one special case left
  166. $ cc [-.vms]vmstermcap.c -
  167.     /Define=("bcopy(s,d,n)=memcpy((d),(s),(n))","exit=vms_exit")
  168. $ libr/Obj 'nethacklib' vmstermcap.obj/Insert
  169. $!
  170. $link:
  171. $ milestone "<linking...>"
  172. $ link/Exe=nethack 'nethacklib'/Lib/Incl=(vmsmain,allmain,vmsunix,vmstty,decl),-
  173.     sys$disk:[]monst.obj,objects.obj,-    !(data-only modules, like decl)
  174.     sys$input:/Opt,'vaxcrtl''gnulib'
  175. identification="NetHack 3.0.9"
  176. $ milestone "NetHack"
  177. $     if c_opt.eq.10 then  goto done    !"LINK" only
  178. $special:
  179. $!
  180. $! build special level compiler
  181. $!
  182. $ cc lev_main.c
  183. $ cc lev_comp.c
  184. $ copy [-.vms]lev_lex.h stdio.*/Prot=(s:rwd,o:rwd)
  185. $ cc lev_lex.c
  186. $ rename stdio.h lev_lex.*
  187. $ cc panic.c
  188. $ link lev_comp.obj,lev_lex.obj,lev_main.obj,-
  189.     monst.obj,objects.obj,alloc.obj,panic.obj,vmsmisc.obj,-
  190.     'vaxcrtl''gnulib',sys$input:/Opt
  191. identification="lev_comp 3.0.9"
  192. $ milestone "lev_comp"
  193. $!
  194. $done:
  195. $ exit
  196.